package com.thwj.project.app.service;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.thwj.common.exception.ServiceException;
import com.thwj.common.utils.StringUtils;
import com.thwj.common.utils.WzDateUtil;
import com.thwj.framework.mybatis_plus.GeoUtil;
import com.thwj.framework.security.LoginUser;
import com.thwj.framework.web.service.TokenService;
import com.thwj.project.amap.AMapService;
import com.thwj.project.amap.dto.AppLocationDTO;
import com.thwj.project.app.api.param.DynamicCommentParam;
import com.thwj.project.app.api.param.DynamicParam;
import com.thwj.project.app.api.vo.DynamicCommentVo;
import com.thwj.project.app.api.vo.DynamicTagVo;
import com.thwj.project.app.api.vo.DynamicVo;
import com.thwj.project.app.convert.PicV2Convert;
import com.thwj.project.app.event.DynamicOperateEvent;
import com.thwj.project.app.event.UserMessageEvent;
import com.thwj.project.biz.domain.*;
import com.thwj.project.biz.enums.AuditStatusEnum;
import com.thwj.project.biz.enums.MessageTypeEnum;
import com.thwj.project.biz.service.*;
import com.thwj.project.secCheck.SecCheckUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

@Transactional
@Service
public class AppDynamicsService {

    @Autowired
    IDynamicService dynamicService;
    @Autowired
    ApplicationEventPublisher applicationEventPublisher;
    @Autowired
    UserInfoResolver userInfoResolver;
    @Autowired
    UserVipResolver userVipResolver;
    @Autowired
    IDynamicCommentService dynamicCommentService;
    @Autowired
    IDynamicGoodService dynamicGoodService;
    @Autowired
    SecCheckUtil secCheckUtil;
    @Autowired
    AMapService aMapService;
    @Autowired
    TokenService tokenService;
    @Autowired
    IActivityCategoryService activityCategoryService;
    @Autowired
    IUserAttentionService userAttentionService;
    @Autowired
    IUserDdService userDdService;

    public Page<DynamicVo> getDynamicsPage(Page page, Long cityCode,LoginUser loginUser) {
        Page<Dynamic> dynamicPage = dynamicService.page(page,
                new QueryWrapper<Dynamic>().eq("status", AuditStatusEnum.auditing_success.getValue()).eq("valid", true)
                        .and(w->w.eq("code_city", cityCode).or().isNull("code_city")).orderByDesc("create_date")
        );
        if(CollectionUtils.isEmpty(dynamicPage.getRecords())) {
            return page;
        }
        List<Long> dynamicIdList = dynamicPage.getRecords().stream().map(Dynamic::getId).collect(Collectors.toList());
        // 读取动态的评论
        List<DynamicComment> commentList = dynamicCommentService.list(
                new QueryWrapper<DynamicComment>()
                        .in("dynamic_id",dynamicIdList)
                        .eq("valid",true)
                        .eq("status",AuditStatusEnum.auditing_success.getValue())
                        .orderByAsc("create_date")
        );
        // 判断当前用户是否当前了这批id动态
        List<DynamicGood> dynamicGoodList = dynamicGoodService.list(new QueryWrapper<DynamicGood>()
                .eq("user_id", loginUser.getUserId())
                .eq("valid", true)
                .in("dynamic_id", dynamicIdList)
        );
        //查看当前登录人和发布动态的用户是否存在didi记录
        List<Long> dynamicUserIdList = dynamicPage.getRecords().stream().map(Dynamic::getUserId).distinct().collect(Collectors.toList());
        List<UserDd> userDdList = userDdService.list(new QueryWrapper<UserDd>()
                .eq("send_user_id", loginUser.getUserId())
                .in("received_user_id", dynamicUserIdList)
        );

        List<DynamicVo> dynamicVoList = new ArrayList<>();
        dynamicPage.getRecords().forEach(item->{
            DynamicVo dynamicVo = convertDynamicVo(item, loginUser);
            List<DynamicComment> commentListItem = commentList.stream().filter(DO->DO.getDynamicId().compareTo(item.getId()) == 0).collect(Collectors.toList());
            if(!CollectionUtils.isEmpty(commentListItem)) {
                convertDynamicCommentVoList(dynamicVo, commentListItem, loginUser);
            }
            List<DynamicGood> dynamicGoodListItem = dynamicGoodList.stream().filter(DO->DO.getDynamicId().compareTo(item.getId()) == 0).collect(Collectors.toList());
            if(!CollectionUtils.isEmpty(dynamicGoodListItem)) {
                dynamicVo.setGoodOrNot(true);
            }

            List<UserDd> userDdListItem = userDdList.stream().filter(DO->DO.getReceivedUserId().compareTo(item.getUserId()) == 0).collect(Collectors.toList());
            if(!CollectionUtils.isEmpty(userDdListItem)) {
                dynamicVo.setDidiOrNot(true);
            }
            dynamicVoList.add(dynamicVo);
        });


        // 更新用户昵称和头像信息
        userInfoResolver.resolve(dynamicVoList,DynamicVo::getUserId,((obj, nickName, headPic) -> {
            obj.setUserNickName(nickName);
            obj.setUserHeadPic(headPic);
        }));
        // VIP标签
        userVipResolver.resolve(dynamicVoList,DynamicVo::getUserId,((obj, vipOrNot) -> {
            obj.setVipOrNot(vipOrNot);
        }));


        page.setRecords(dynamicVoList);
        return page;
    }

    public DynamicVo getDynamicsDetail(Long dynamicId, LoginUser loginUser) {

        Dynamic dynamic = dynamicService.getById(dynamicId);
        if(dynamic == null) {
            throw new ServiceException("动态不存在");
        }
        // 读取动态VO信息
        DynamicVo dynamicVo = convertDynamicVo(dynamic,loginUser);
        // 读取评论列表信息
        List<DynamicComment> commentList = dynamicCommentService.list(
                new QueryWrapper<DynamicComment>()
                        .eq("dynamic_id",dynamic.getId())
                        .eq("valid",true)
                        .eq("status",AuditStatusEnum.auditing_success.getValue())
                        .orderByAsc("create_date")
        );
        convertDynamicCommentVoList(dynamicVo, commentList,loginUser);

        // 判断当前用户是否当前了这批id动态
        DynamicGood dynamicGood = dynamicGoodService.getOne(new QueryWrapper<DynamicGood>()
                .eq("user_id", loginUser.getUserId())
                .eq("valid", true)
                .eq("dynamic_id", dynamicId)
        );
        if(dynamicGood != null) {
            dynamicVo.setGoodOrNot(true);
        }

        // 更新用户信息
        userInfoResolver.resolve(dynamicVo,DynamicVo::getUserId,((obj, nickName, headPic) -> {
            obj.setUserNickName(nickName);
            obj.setUserHeadPic(headPic);
        }));
        // VIP标签
        userVipResolver.resolve(dynamicVo,DynamicVo::getUserId,((obj, vipOrNot) -> {
            obj.setVipOrNot(vipOrNot);
        }));
        // 浏览事件
        applicationEventPublisher.publishEvent(
                DynamicOperateEvent.builder()
                        .userId(loginUser.getUserId())
                        .dynamic(dynamic)
                        .operateType(DynamicOperateEvent.DynamicOperateType.LOOK)
                        .build()
        );

        return dynamicVo;
    }



    public void commitDynamicGood(Long dynamicId, LoginUser loginUser) {

        Dynamic dynamic = dynamicService.getById(dynamicId);
        if(dynamic == null) {
            throw new ServiceException("动态不存在");
        }
        // 读取用户是否存在点赞记录
        DynamicGood dynamicGood = dynamicGoodService.getOne(
                new QueryWrapper<DynamicGood>().eq("user_id", loginUser.getUserId()).eq("dynamic_id",dynamicId),false
        );
        if (dynamicGood == null) {
            dynamicGood = new DynamicGood();
            dynamicGood.setDynamicId(dynamicId);
            dynamicGood.setAuthorUserId(dynamic.getUserId());
            dynamicGood.setUserId(loginUser.getUserId());
            dynamicGood.setValid(false);
            dynamicGood.setCreateDate(new Date());
        }
        dynamicGood.setValid(!dynamicGood.getValid());
        dynamicGoodService.saveOrUpdate(dynamicGood);
        // 发布事件
        applicationEventPublisher.publishEvent(
                DynamicOperateEvent.builder()
                        .operateType(dynamicGood.getValid()?DynamicOperateEvent.DynamicOperateType.GOOD:DynamicOperateEvent.DynamicOperateType.CANCEL_GOOD)
                        .userId(loginUser.getUserId())
                        .dynamic(dynamic)
                        .build()
        );

        String firstPic = null;
        if(!StringUtils.isEmpty(dynamic.getPicList())) {
            firstPic = dynamic.getPicList().split(",")[0];
        }

        if(dynamicGood.getValid()) {
            applicationEventPublisher.publishEvent(UserMessageEvent.builder()
                    .userId(dynamic.getUserId())
                    .type(MessageTypeEnum.DYNAMICS_MESSAGE)
                    .withContent("点赞了你发布的动态")
                    .withDynamicParam(dynamic.getId(), firstPic ,dynamic.getContent(),loginUser.getUserId()).build());
        }
    }

    public void commitDynamicComment(DynamicCommentParam dynamicCommentParam, LoginUser loginUser) {
        Dynamic dynamic = dynamicService.getById(dynamicCommentParam.getDynamicId());
        if(dynamic == null) {
            throw new ServiceException("动态不存在");
        }
        //先进性文字内容的安全识别
        boolean isSecurity = secCheckUtil.checkContentSecurity(dynamicCommentParam.getCommentContent());
        if(!isSecurity) {
            throw new ServiceException("评论内容不合法，请文明用语");
        }
        // 新增评论
        DynamicComment insert = new DynamicComment();
        insert.setValid(true);
        insert.setStatus(AuditStatusEnum.auditing_success.getValue());
        insert.setCreateDate(new Date());
        // 入参信息
        insert.setDynamicId(dynamicCommentParam.getDynamicId());
        insert.setUserId(loginUser.getUserId());
        insert.setContent(dynamicCommentParam.getCommentContent());
        // 如果是回复别人的评论这里需要读取一下 评论发起的用户di
        if(dynamicCommentParam.getReplyCommentId() != null) {
            DynamicComment selectReply = dynamicCommentService.getById(dynamicCommentParam.getReplyCommentId());
            insert.setParentCommentId(selectReply.getId());
            insert.setParentCommentUserId(selectReply.getUserId());
        }
        dynamicCommentService.save(insert);

        // 评论事件
        applicationEventPublisher.publishEvent(
                DynamicOperateEvent.builder()
                        .operateType(DynamicOperateEvent.DynamicOperateType.COMMENT)
                        .userId(loginUser.getUserId())
                        .dynamic(dynamic)
                        .build()
        );

        String firstPic = null;
        if(!StringUtils.isEmpty(dynamic.getPicList())) {
            firstPic = dynamic.getPicList().split(",")[0];
        }
        applicationEventPublisher.publishEvent(UserMessageEvent.builder()
                .userId(insert.getParentCommentUserId() == null ? dynamic.getUserId(): insert.getParentCommentUserId())
                .type(MessageTypeEnum.DYNAMICS_MESSAGE)
                .withContent("评论：" + insert.getContent())
                .withDynamicParam(dynamic.getId(), firstPic ,dynamic.getContent(),loginUser.getUserId()).build());
    }

    public void commitDynamic(DynamicParam dynamicParam, LoginUser loginUser) {

        Dynamic insert = new Dynamic();
        insert.setCreateDate(new Date());
        insert.setDateDay(WzDateUtil.getBeginOfTheDay(new Date()));
        insert.setUserId(loginUser.getUserId());

        insert.setContent(dynamicParam.getContent());
        insert.setPicList(dynamicParam.getPicList());
        // 默认审核中
        insert.setStatus(AuditStatusEnum.auditing.getValue());
        // 标签
        insert.setTagJson(JSON.toJSONString(dynamicParam.getTagParamList()));
        // 用户发送动态的位置
        Double lngLatArray[] = tokenService.getLngLatArray();
        if(lngLatArray != null) {
            // 根据经纬度获取行政区域
            AppLocationDTO appLocationDTO = aMapService.getAppLocationDTO(lngLatArray[0] + "," + lngLatArray[1]);
            if (appLocationDTO != null) {
                insert.setCodeProv(appLocationDTO.getCodeProv());
                insert.setNameProv(appLocationDTO.getNameProv());
                insert.setCodeCity(appLocationDTO.getCodeCity());
                insert.setNameCity(appLocationDTO.getNameCity());
                insert.setCodeDistrict(appLocationDTO.getCodeDistrict());
                insert.setNameDistrict(appLocationDTO.getNameDistrict());
            }
            insert.setLongitude(lngLatArray[0]);
            insert.setLatitude(lngLatArray[1]);
            // mysql gem
            insert.setLocation(GeoUtil.getWgs84Point(insert.getLatitude(),insert.getLongitude()));
        }
        dynamicService.save(insert);

        // 发布事件
        applicationEventPublisher.publishEvent(
                DynamicOperateEvent.builder()
                        .operateType(DynamicOperateEvent.DynamicOperateType.PUBLISH)
                        .userId(loginUser.getUserId())
                        .dynamic(insert)
                        .build()
        );
    }



    private DynamicVo convertDynamicVo(Dynamic dynamic, LoginUser loginUser) {
        DynamicVo dynamicVo = new DynamicVo();
        dynamicVo.setId(dynamic.getId());
        dynamicVo.setUserId(dynamic.getUserId());
        dynamicVo.setStatus(dynamic.getStatus());
        dynamicVo.setPicList(dynamic.getPicList());
        dynamicVo.setPicListV2(PicV2Convert.getPicListV2(dynamic.getPicList()));
        dynamicVo.setContent(dynamic.getContent());
        dynamicVo.setTagVoList(JSON.parseArray(dynamic.getTagJson(), DynamicTagVo.class));
        dynamicVo.setCommentCount(dynamic.getCommentCount());
        dynamicVo.setGoodCount(dynamic.getGoodCount());
        dynamicVo.setLookCount(dynamic.getLookCount());
        dynamicVo.setCreateDate(WzDateUtil.getShortTime(dynamic.getCreateDate()));

        if(loginUser != null && dynamic.getUserId().compareTo(loginUser.getUserId()) == 0) {
            dynamicVo.setMyself(true);
        }

        return dynamicVo;
    }

    private DynamicVo convertDynamicCommentVoList(DynamicVo dynamicVo, List<DynamicComment> commentList,LoginUser loginUser) {
        List<DynamicCommentVo> commentVoList = new ArrayList<>();
        dynamicVo.setCommentVoList(commentVoList);
        // 遍历数据
        for (DynamicComment dbComment : commentList) {
            DynamicCommentVo commentVo = new DynamicCommentVo();
            commentVo.setId(dbComment.getId());

            commentVo.setCommentContent(dbComment.getContent());
            commentVo.setCommentDate(WzDateUtil.getShortTime(dbComment.getCreateDate()));
            commentVo.setCommentUserId(dbComment.getUserId());
            if(dbComment.getUserId().compareTo(loginUser.getUserId()) == 0) {
                commentVo.setMyself(true);
            }

            commentVo.setReplyUserId(dbComment.getParentCommentUserId());

            commentVo.setCommentContent(dbComment.getContent());

            commentVoList.add(commentVo);
        }
        dynamicVo.setCommentVoList(commentVoList);
        // 统一处理相关昵称 评论人昵称
        userInfoResolver.resolve(commentVoList,DynamicCommentVo::getCommentUserId,((obj, nickName, headPic) -> {
            obj.setCommentUserNickName(nickName);
        }));
        // 统一处理相关昵称 评论是回复哪个人昵称
        userInfoResolver.resolve(commentVoList,DynamicCommentVo::getReplyUserId,((obj, nickName, headPic) -> {
            obj.setReplyUserNickName(nickName);
        }));
        return dynamicVo;
    }

    public void deleteDynamic(Long dynamicId, LoginUser loginUser) {
        Dynamic dynamic = dynamicService.getById(dynamicId);
        if(dynamic == null) {
            throw new ServiceException("动态不存在");
        }
        if(dynamic.getUserId().longValue() != loginUser.getUserId().longValue()){
            throw new ServiceException("操作异常，非本人，不可删除");
        }
        dynamic.setValid(false);
        dynamicService.updateById(dynamic);
    }

    public void deleteDynamicComment(Long commentId, LoginUser loginUser) {
        DynamicComment deleteDynamic = dynamicCommentService.getById(commentId);
        if(deleteDynamic == null) {
            throw new ServiceException("评论不存在");
        }
        if(!deleteDynamic.getValid()){
            throw new ServiceException("评论已删除");
        }
        Dynamic dynamic = dynamicService.getById(deleteDynamic.getDynamicId());
        if(dynamic == null) {
            throw new ServiceException("动态不存在");
        }
        deleteDynamic.setValid(false);
        dynamicCommentService.updateById(deleteDynamic);
        // 删除评论事件
        applicationEventPublisher.publishEvent(
                DynamicOperateEvent.builder()
                        .operateType(DynamicOperateEvent.DynamicOperateType.DELETE_COMMENT)
                        .userId(loginUser.getUserId())
                        .dynamic(dynamic)
                        .build()
        );

    }

    public List<DynamicTagVo> getDynamicsTagList() {
        // 读取分类
        List<ActivityCategory> categoryList = activityCategoryService.list(null);
        List<DynamicTagVo> tagVoList =new ArrayList<>();
        categoryList.forEach(item->{
            DynamicTagVo tagVo = new DynamicTagVo();
            tagVo.setTagName(item.getName());
            tagVo.setTagId(item.getId());
            tagVo.setTagType(1);
            tagVoList.add(tagVo);
        });

        return tagVoList;
    }

    public Page<DynamicVo> getUserDynamicsPage(Page page,Long userId, LoginUser loginUser) {
        Page<Dynamic> dynamicPage = dynamicService.page(page,
                new QueryWrapper<Dynamic>().eq("user_id", userId)
                        .eq("status", AuditStatusEnum.auditing_success.getValue())
                        .eq("valid", true)
                        .orderByDesc("create_date")
        );
        if(CollectionUtils.isEmpty(dynamicPage.getRecords())) {
            return page;
        }
        List<Long> dynamicIdList = dynamicPage.getRecords().stream().map(Dynamic::getId).collect(Collectors.toList());
        // 读取动态的评论
        List<DynamicComment> commentList = dynamicCommentService.list(
                new QueryWrapper<DynamicComment>()
                        .in("dynamic_id",dynamicIdList)
                        .eq("valid",true)
                        .eq("status",AuditStatusEnum.auditing_success.getValue())
                        .orderByAsc("create_date")
        );
        // 判断当前用户是否点赞当前了这批id动态
        List<DynamicGood> dynamicGoodList = dynamicGoodService.list(new QueryWrapper<DynamicGood>()
                .eq("user_id", loginUser.getUserId())
                .eq("valid", true)
                .in("dynamic_id", dynamicIdList)
        );
        //查看当前登录人和发布动态的用户是否存在didi记录
        List<Long> dynamicUserIdList = dynamicPage.getRecords().stream().map(Dynamic::getUserId).distinct().collect(Collectors.toList());
        List<UserDd> userDdList = userDdService.list(new QueryWrapper<UserDd>()
                .eq("send_user_id", loginUser.getUserId())
                .in("received_user_id", dynamicUserIdList)
        );
        List<DynamicVo> dynamicVoList = new ArrayList<>();
        dynamicPage.getRecords().forEach(item->{
            DynamicVo dynamicVo = convertDynamicVo(item, loginUser);
            List<DynamicComment> commentListItem = commentList.stream().filter(DO->DO.getDynamicId().compareTo(item.getId()) == 0).collect(Collectors.toList());
            if(!CollectionUtils.isEmpty(commentListItem)) {
                convertDynamicCommentVoList(dynamicVo, commentListItem, loginUser);
            }
            List<DynamicGood> dynamicGoodListItem = dynamicGoodList.stream().filter(DO->DO.getDynamicId().compareTo(item.getId()) == 0).collect(Collectors.toList());
            if(!CollectionUtils.isEmpty(dynamicGoodListItem)) {
                dynamicVo.setGoodOrNot(true);
            }

            List<UserDd> userDdListItem = userDdList.stream().filter(DO->DO.getReceivedUserId().compareTo(item.getUserId()) == 0).collect(Collectors.toList());
            if(!CollectionUtils.isEmpty(userDdListItem)) {
                dynamicVo.setDidiOrNot(true);
            }
            dynamicVoList.add(dynamicVo);
        });
        // 更新用户昵称和头像信息
        userInfoResolver.resolve(dynamicVoList,DynamicVo::getUserId,((obj, nickName, headPic) -> {
            obj.setUserNickName(nickName);
            obj.setUserHeadPic(headPic);
        }));
        // VIP标签
        userVipResolver.resolve(dynamicVoList,DynamicVo::getUserId,((obj, vipOrNot) -> {
            obj.setVipOrNot(vipOrNot);
        }));


        page.setRecords(dynamicVoList);
        return page;
    }

    public Page<DynamicVo> getUserRecDynamicsPage(Page page, LoginUser loginUser) {
        // 读取当前用户关注的用户列表
        List<UserAttention> userAttentionList = userAttentionService.list(
                new QueryWrapper<UserAttention>()
                .eq("user_id", loginUser.getUserId())
                .eq("valid",true)
        );
        if(CollectionUtils.isEmpty(userAttentionList)) {
            return page;
        }
        List<Long> userIdList = userAttentionList.stream().map(UserAttention::getAttentionUserId).collect(Collectors.toList());
        Page<Dynamic> dynamicPage = dynamicService.page(page,
                new QueryWrapper<Dynamic>().eq("status", AuditStatusEnum.auditing_success.getValue()).eq("valid", true)
                        .in("user_id", userIdList).orderByDesc("create_date")
        );
        if(CollectionUtils.isEmpty(dynamicPage.getRecords())) {
            return page;
        }
        List<Long> dynamicIdList = dynamicPage.getRecords().stream().map(Dynamic::getId).collect(Collectors.toList());
        // 读取动态的评论
        List<DynamicComment> commentList = dynamicCommentService.list(
                new QueryWrapper<DynamicComment>()
                        .in("dynamic_id",dynamicIdList)
                        .eq("valid",true)
                        .eq("status",AuditStatusEnum.auditing_success.getValue())
                        .orderByAsc("create_date")
        );
        // 判断当前用户是否当前了这批id动态
        List<DynamicGood> dynamicGoodList = dynamicGoodService.list(new QueryWrapper<DynamicGood>()
                .eq("user_id", loginUser.getUserId())
                .eq("valid", true)
                .in("dynamic_id", dynamicIdList)
        );
        //查看当前登录人和发布动态的用户是否存在didi记录
        List<Long> dynamicUserIdList = dynamicPage.getRecords().stream().map(Dynamic::getUserId).distinct().collect(Collectors.toList());
        List<UserDd> userDdList = userDdService.list(new QueryWrapper<UserDd>()
                .eq("send_user_id", loginUser.getUserId())
                .in("received_user_id", dynamicUserIdList)
        );


        List<DynamicVo> dynamicVoList = new ArrayList<>();
        dynamicPage.getRecords().forEach(item->{
            DynamicVo dynamicVo = convertDynamicVo(item, loginUser);
            List<DynamicComment> commentListItem = commentList.stream().filter(DO->DO.getDynamicId().compareTo(item.getId()) == 0).collect(Collectors.toList());
            if(!CollectionUtils.isEmpty(commentListItem)) {
                convertDynamicCommentVoList(dynamicVo, commentListItem, loginUser);
            }
            List<DynamicGood> dynamicGoodListItem = dynamicGoodList.stream().filter(DO->DO.getDynamicId().compareTo(item.getId()) == 0).collect(Collectors.toList());
            if(!CollectionUtils.isEmpty(dynamicGoodListItem)) {
                dynamicVo.setGoodOrNot(true);
            }

            List<UserDd> userDdListItem = userDdList.stream().filter(DO->DO.getReceivedUserId().compareTo(item.getUserId()) == 0).collect(Collectors.toList());
            if(!CollectionUtils.isEmpty(userDdListItem)) {
                dynamicVo.setDidiOrNot(true);
            }
            dynamicVoList.add(dynamicVo);
        });


        // 更新用户昵称和头像信息
        userInfoResolver.resolve(dynamicVoList,DynamicVo::getUserId,((obj, nickName, headPic) -> {
            obj.setUserNickName(nickName);
            obj.setUserHeadPic(headPic);
        }));
        // VIP标签
        userVipResolver.resolve(dynamicVoList,DynamicVo::getUserId,((obj, vipOrNot) -> {
            obj.setVipOrNot(vipOrNot);
        }));


        page.setRecords(dynamicVoList);
        return page;
    }
}
